package com.ym.b2b.salesman.dao.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.ym.b2b.salesman.dao.EmBSalesmanProviderDAO;
import com.ym.b2b.salesman.sqlbean.EmBSalesmanProvider;
import com.zc.commons.base.Page;
import com.zc.commons.dao.ZcDao;

@Repository
public class EmBSalesmanProviderDAOImpl<T> extends ZcDao<T> implements EmBSalesmanProviderDAO {

    public Long searchPageEmBSalesmanProviderNum(EmBSalesmanProvider embsalesmanprovider) throws DataAccessException {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", embsalesmanprovider);
        return (Long) find("EM_B_SALESMAN_PROVIDER.searchPageEmBSalesmanProviderNum", map);
    }

    public Page searchPageEmBSalesmanProvider(EmBSalesmanProvider embsalesmanprovider, Page<EmBSalesmanProvider> page)
                                                                                                                      throws DataAccessException {
        page.setTotalRow(searchPageEmBSalesmanProviderNum(embsalesmanprovider));
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", embsalesmanprovider);
        map.put("startrow", page.getStartRow());
        map.put("pagesize", page.getPageSize());
        map.put("pageable", page.getPageable());
        page.setRows(list("EM_B_SALESMAN_PROVIDER.searchPageEmBSalesmanProvider", map));
        return page;
    }

    public void insertEmBSalesmanProvider(EmBSalesmanProvider record) throws DataAccessException {
        insert("EM_B_SALESMAN_PROVIDER.insertEmBSalesmanProvider", record);
    }

    public int updateEmBSalesmanProvider(EmBSalesmanProvider record) throws DataAccessException {
        int rows = update("EM_B_SALESMAN_PROVIDER.updateEmBSalesmanProvider", record);
        return rows;
    }

    public EmBSalesmanProvider searchEmBSalesmanProvider(Long salesmanProviderId) throws DataAccessException {
        EmBSalesmanProvider key = new EmBSalesmanProvider();
        key.setSalesmanProviderId(salesmanProviderId);
        EmBSalesmanProvider record = (EmBSalesmanProvider) find("EM_B_SALESMAN_PROVIDER.selectEmBSalesmanProvider", key);
        return record;
    }

    @Override
    public void deleteEmBSalesmanProvider(EmBSalesmanProvider record) throws DataAccessException {
        delete("EM_B_SALESMAN_PROVIDER.deleteEmBSalesmanProvider", record);
    }

    @Override
    public void deleteMultipleEmBSalesmanProviders(String belongIdList) {
        delete("EM_B_SALESMAN_PROVIDER.deleteMultipleEmBSalesmanProviders", belongIdList);
    }
}
